﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UpdatePrUnitNameAll]

AS
BEGIN
	DECLARE @NSI_PU_ID int
	DECLARE @NewName nvarchar(50)
	DECLARE @cursor CURSOR
	
	SET @cursor = CURSOR SCROLL FOR
		SELECT ID, SHORT_NAME FROM NSI_PRODUCT
	
	open @cursor
	
	FETCH NEXT FROM @cursor INTO @NSI_PU_ID, @NewName
	
	WHILE @@FETCH_STATUS = 0
	BEGIN
		UPDATE PRODUCT_UNIT SET NAME = @NewName WHERE NSI_PRODUCT_ID = @NSI_PU_ID
		FETCH NEXT FROM @cursor INTO @NSI_PU_ID, @NewName
	END
	
	close @cursor
END